<?php
/**
 * created by zzy
 * date: 2017/10/24 9:28
 */
namespace App\Eloquent\Ygt;

class Appindex extends DbEloquent{

    public static $fields = 'type,title,img_url,img_url_active';
    protected $table    = 'ygt_appindex';

    public static function getListByPid( $pid ){

        $where              = [ 'pid'=>$pid,'status'=>1 ];
        $lists              = self::getList( $where, '','','',['orderby','desc'] );
        $result             = [];
        if( $lists->isNotEmpty() ){
            $listsArr                      = $lists->toArray();
            foreach( $listsArr as $key=>$val ){
                $imgUrl                    = $imgUrlActive = '';
                if( $val['img_url'] ){
                    $imgUrl                = asset( $val['img_url'] );
                }
                if( $val['img_url'] ){
                    $imgUrlActive         = asset( $val['img_url_active'] );
                }
                $val['img_url']            = $imgUrl;
                $val['img_url_active']    = $imgUrlActive;
                $result[]                   = $val;
            }
        }
        return $result;
    }

}
